import { View } from "../../../../mvc/core/View";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { BaseItem } from "../../common/BaseItem";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { CopyMountBackInfo } from "./CopyMountBackInfo";
import { ItemData } from "../../../resource/info/ItemData";
import { WardrobeConfig } from "../../../resource/WardrobeConfig";
import { Language } from "../../../../../extend/language/Language";
import { GameConst } from "../../../../component/gconst/GameConst";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
type int = number;
//class CopyMountBackSp
    
    export  class CopyMountBackSp extends View
    {
        constructor()
        {
            super();
            this.buttonMode = true;
            this.useHandCursor = true;
            this.mouseChildren = false;
            this.initView();
            return;
        }

        /* internal  */initView(): void
        {
            this._bg = ObjCreate.createBitmap("", 0, 0);
            addChild(this._bg);
            this._nameBg = ObjCreate.createBg(9, 10, 92, 20, this, ImagesConst.FightingStrgBg);
            this._nameTxt = ObjCreate.createTextField("", 0, 12, 106, 20, this);
            this._nameTxt.autoSize = flash.text.TextFieldAutoSize.CENTER;
            this._itemBg = ObjCreate.createBg(22, 34, 65, 65, this, ImagesConst.PackItemBg);
            this._baseItem = new BaseItem();
            this._baseItem.move(25, 37);
            this._baseItem.setSize(60, 60);
            this._baseItem.setAmountLabelPos(0, 45);
            this._baseItem.isDragAble = false;
            this._baseItem.isDropAble = false;
            this._baseItem.isShowLock = false;
            this._baseItem.isShowToolTip = false;
            addChild(this._baseItem);
            ObjCreate.createBg(0, 106, 90, 22, this, ImagesConst.yellowBoxCell);
            this._costTx = ObjCreate.createTextField("", 0, 106, 106, 24, this, new GTextFormat(FontUtil.songtiName, 14, 15788607, true, null, null, null, null, flash.text.TextFormatAlign.CENTER));
            this._equipOwnedBmp = ObjCreate.createBitmap("", 33, 43, this);
            addChild(this._equipOwnedBmp);
            LoaderHelp.addResCallBack(ResFileConst.copyMount, this.onLoadBmResource);
            return;
        }

        /* internal  */onLoadBmResource(): void
        {
            this._bg.bitmapData = GlobalClass.getBitmapData(ImagesConst.copyMount_backbg);
            return;
        }

        public setData(arg1: CopyMountBackInfo): void
        {
            if (arg1.isHad != 1) 
            {
                this._equipOwnedBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.EquipNotOwnedSm);
                this.updateCost(1);
            }
            else 
            {
                this._equipOwnedBmp.bitmapData = GlobalClass.getBitmapData(ImagesConst.EquipOwnedSm);
                this.updateCost(0);
            }
            this._idata = new ItemData(WardrobeConfig.instance.getCodeByModelId(arg1.modelId));
            if (this._idata && !(this._idata == ItemData.nullItemData) && !(this._idata.itemInfo == null)) 
            {
                this._baseItem.itemData = this._idata;
                this._nameTxt.text = WardrobeConfig.instance.getNameByModelId(arg1.modelId);
            }
            else 
            {
                this._baseItem.itemData = null;
                this._nameTxt.text = "";
            }
            return;
        }

        public updateCost(arg1: int): void
        {
            var loc1=arg1;
            switch (loc1) 
            {
                case 0:
                {
                    this._costTx.text = Language.getString(79005);
                    this.cost = 0;
                    break;
                }
                case 1:
                {
                    this.cost = GameConst.MountCopyConsume1;
                    this._costTx.text = Language.getStringByParam(79006, this.cost);
                    break;
                }
                case 2:
                {
                    this.cost = GameConst.MountCopyConsume2;
                    this._costTx.text = Language.getStringByParam(79006, this.cost);
                    break;
                }
                case 3:
                {
                    this.cost = GameConst.MountCopyConsume3;
                    this._costTx.text = Language.getStringByParam(79006, this.cost);
                    break;
                }
                case 4:
                {
                    this.cost = GameConst.MountCopyConsume4;
                    this._costTx.text = Language.getStringByParam(79006, this.cost);
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }

        /* internal */ /* var */_equipOwnedBmp: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_idata: ItemData;

        /* internal */ /* var */_bg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_nameTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_baseItem: BaseItem;

        /* internal */ /* var */_nameBg: ScaleBitmap;

        /* internal */ /* var */_itemBg: ScaleBitmap;

        /* internal */ /* var */_costTx: Object /* flash.text.TextField */;

        public /* var */cost: int;
    }
